package com.ruoyi.archive.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.archive.domain.SSoldierFormInfo;
import com.ruoyi.archive.mapper.SSoldierFormInfoMapper;
import com.ruoyi.archive.service.ISSoldierFormInfoService;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.apache.commons.beanutils.ConvertUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @program: ruoyi
 * @description:
 * @author: yuxiang
 * @create: 2021-10-09 15:26
 */
@Service
public class SSoldierFormInfoServiceImpl extends ServiceImpl<SSoldierFormInfoMapper, SSoldierFormInfo> implements ISSoldierFormInfoService {
    @Autowired
    private SSoldierFormInfoMapper soldierFormInfoMapper;

    @Override
    public int saveSoldierForm(Long soldierId, String formId) {
        if (StringUtils.isNotEmpty(formId)) {
            List<Integer> formIdList = Arrays.asList((Integer[]) ConvertUtils.convert(formId.split(","), Integer.class));
            int batchCount = soldierFormInfoMapper.insertBatch(soldierId,formIdList);
            return batchCount;
        }
        return 0;
    }
}
